//<%@ taglib prefix="jj" uri="http://jaxson.org/base" %>

//<jj:import>
org.jaxson.util.collections.Map;
org.jaxson.util.collections.List;
//</jj:import>

namespace( "org.jaxson.util.collections" );
org.jaxson.util.collections.MappedList = function(){

	var sup = "org.jaxson.util.collections.Map";
	
	function getList(key){
		var list = new org.jaxson.util.collections.List();
		if( that.getSuperClass(sup).get(key) !== null ){
			list = that.getSuperClass(sup).get(key);
		}
		that.getSuperClass(sup).put( key, list );
		return list;
	};

	var that = {
		put : function( key, value ){
			getList(key).add( value );
		},
		
		remove : function( key ){
			getList(key).clear();
			that.getSuperClass(sup).remove(key);
		},
		
		clear : function(){
			var values = that.values().asArray();
			for( i in values ){
				values[i].clear();
			}
			that.getSuperClass(sup).clear();
		}
	};
	
	inherits( sup, "org.jaxson.util.collections.MappedList", that );
	
	return that;
};
